package com.elvin.platform.udp;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.ip.udp.UnicastSendingMessageHandler;

/**
 * IntegrationClientConfig*/
@Configuration
public class UdpIntegrationClientConfig {

  @Value("${udp.host}")
  private String udpHost;
  @Value("${udp.port}")
  private Integer udpPort;

  @Bean
  @ServiceActivator(inputChannel = "udpOut")
  public UnicastSendingMessageHandler unicastSendingMessageHandler() {
    //UnicastSendingMessageHandler unicastSendingMessageHandler = new UnicastSendingMessageHandler("localhost", 6001);
    UnicastSendingMessageHandler unicastSendingMessageHandler = new UnicastSendingMessageHandler(udpHost, udpPort);
    return unicastSendingMessageHandler;
  }

}

